<?php
/**
 * @package		Joomla.Site
 * @subpackage	com_content
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;

// Create a shortcut for params.
$params = &$this->item->params;
$images = json_decode($this->item->images);
$canEdit	= $this->item->params->get('access-edit');
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::core();

?>
					<h3><a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>"><?php echo $this->item->title; ?></a></h3>
					<h4>
<?php if ($params->get('show_publish_date')) : ?>
		
		<?php echo JText::sprintf('COM_CONTENT_PUBLISHED_DATE_ON', JHtml::_('date',$this->item->publish_up, JText::_('DATE_FORMAT_LC2'))); ?>
		
<?php endif; ?>	
					<?php $author =  $this->item->author; ?>
		<?php $author = ($this->item->created_by_alias ? $this->item->created_by_alias : $author);?>
			
			<?php if (!empty($this->item->contactid ) &&  $params->get('link_author') == true):?>
			
				<?php 	echo JText::sprintf('COM_CONTENT_WRITTEN_BY' ,
				 JHtml::_('link',JRoute::_('index.php?option=com_contact&view=contact&id='.$this->item->contactid),$author)); ?>

			<?php else :?>
				<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY','<a href="#" class="cf5">'.$author.'</a>'); ?>
			<?php endif; ?>
			
		

			
<?php if ($params->get('show_category')) : ?>

			<?php $title = $this->escape($this->item->category_title);
					$url = '<a class="cf5 tdu" href="' . JRoute::_(ContentHelperRoute::getCategoryRoute($this->item->catid)) . '">' . $title . '</a>'; ?>
			<?php if ($params->get('link_category')) : ?>
				<?php echo JText::sprintf('COM_CONTENT_CATEGORY',$url); ?>
				<?php else : ?>
				<?php echo JText::sprintf('COM_CONTENT_CATEGORY',$title); ?>
			<?php endif; ?>

<?php endif; ?>

			
					
					</h4>
					<div class="mt10">
					
					<?php
			//code lay hinh
				$arr2 = preg_split('/<(IMG|img) /', $this->item->introtext);
	
	
				//if(sizeof($arr2) <= 1) return '';
			    
			    
				$arr3 = preg_split('/src=\"/', $arr2[1]);
			    
			    
				//if(sizeof($arr3) <= 1) return '';
			    
				$arr4 = preg_split('/\"/', $arr3[1]);
			    
			    
			    
				if(preg_match('/http:/', $arr4[0]))
				{
				    $result = $arr4[0];
				}
				else if(preg_match('/^\//', $arr4[0])){
				    $result = $u2 . substr($arr4[0],1);
				}
				else
				{
				    for($ei = 3; $ei < sizeof($u1) - 1; $ei++)
				    {
					$u2 .= $u1[$ei] . "/";
				    }
				    $result = $u2 . $arr4[0];
				}
			
			?>
					
						<div class="thumbnail">
						<img src="<?php if ($result=="") 
																					echo JURI::base()."/templates/sa/images/gray.png";
																					else echo $result; ?>" alt="" class="" title="<?php echo $item->title; ?>"  width="125" height="63" />
						</div>
						<div class="w520 fr">
							<div class="p">
						<?php 
				
										$arr = explode(" ", strip_tags($this->item->introtext));
										if(count($arr) >= 30)
										{
											$this->item->sintrotext = "";
											for($i=0; $i < 30; $i++)
											{
												$this->item->sintrotext .= $arr[$i]." ";
											}
											//$this->item->sintrotext .= "...";
										}
										else $this->item->sintrotext = strip_tags($this->item->introtext);
										$this->item->sintrotext = str_replace("\"", "", $this->item->sintrotext);
										
										echo $this->item->sintrotext;
										
										preg_match('/\<div class=\"jcomments-links\"(.*?)\>(.*?)\<\/div>/', $this->item->introtext, $match);
										//var_dump($match);
										$comment_link = $match[2];
						?>
							</div>
							<div class="ofh pt5">
								<div class="fs12 fl cmm"><?php echo $comment_link ?></div>
								<div class="fr"><a href=""><img src="images/share.jpg" /></a></div>
							</div>
						</div>
					</div>
					<div class="clear"></div>

<?php echo $this->item->event->afterDisplayContent; ?>
